package vista;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JSeparator;
import javax.swing.JToggleButton;
import javax.swing.ListModel;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.SwingUtilities;

import controlador.ControladorAC;
import dto.PlatoDTO;
import dto.RecetaDTO;
import dto.RubroCartaDTO;
import dto.SucursalDTO;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class AltaCarta extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	{
		// Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager
					.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private JLabel LAltaPlato;
	private JToggleButton bCancelar;
	private JToggleButton bGuardar;
	private JList lRelaciones;
	private JButton bQuitar;
	private JSeparator jSeparator1;
	private JLabel lPlato;
	private JToggleButton bAgregar;
	private JComboBox<String> cPlato;
	private JLabel lRubro;
	private JComboBox<String> cRubro;
	private JLabel lSucursal;
	private JComboBox<String> cRestaurant;

	/**
	 * Auto-generated main method to display this JFrame
	 */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				AltaCarta inst = new AltaCarta();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public AltaCarta() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				LAltaPlato = new JLabel();
				getContentPane().add(LAltaPlato, "Center");
				LAltaPlato.setText("Carta");
				LAltaPlato.setFont(new java.awt.Font("Segoe UI", 1, 18));
				LAltaPlato.setBounds(10, 6, 405, 23);
			}
			{
				//Combo de restaurantes
				cRestaurant = new JComboBox<String>();
				getContentPane().add(cRestaurant);
				cRestaurant.setBounds(106, 40, 444, 22);
				List<SucursalDTO> restaurantes = ControladorAC.getInstancia().listarSucursales();
				for(SucursalDTO s: restaurantes){
					cRestaurant.addItem(s.getNombre());
					
				}
			}
			{
				lSucursal = new JLabel();
				getContentPane().add(lSucursal);
				lSucursal.setText("Sucursal:");
				lSucursal.setBounds(39, 44, 55, 13);
			}
			{
				cRubro = new JComboBox<String>();
				getContentPane().add(cRubro);
				cRubro.setBounds(106, 69, 163, 22);
				List<RubroCartaDTO> rubros = ControladorAC.getInstancia().listarRubros();
				for (RubroCartaDTO r: rubros )
					cRubro.addItem(r.getNombre());
			}
			{
				lRubro = new JLabel();
				getContentPane().add(lRubro);
				lRubro.setText("Rubro:");
				lRubro.setBounds(39, 72, 50, 18);
			}
			{
				cPlato = new JComboBox<String>();
				getContentPane().add(cPlato);
				cPlato.setBounds(380, 71, 170, 20);
				List<PlatoDTO> platos = ControladorAC.getInstancia().listarPlatos();
				for (PlatoDTO p: platos )
					cRubro.addItem(p.getNombre());
				
			}
			{
				bAgregar = new JToggleButton();
				getContentPane().add(bAgregar);
				bAgregar.setText("Agregar");
				bAgregar.setBounds(479, 102, 71, 23);
			}
			{
				lPlato = new JLabel();
				getContentPane().add(lPlato);
				lPlato.setText("Plato:");
				lPlato.setBounds(325, 74, 39, 14);
			}
			{
				lRelaciones = new JList<String>();
				getContentPane().add(lRelaciones);
				lRelaciones.setBounds(106, 102, 363, 261);
				lRelaciones.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				
			}
			{
				bGuardar = new JToggleButton();
				getContentPane().add(bGuardar);
				bGuardar.setText("Guardar");
				bGuardar.setBounds(440, 428, 110, 25);
				bGuardar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("bGuardar.actionPerformed, event="
								+ evt);

					}
				});
			}
			{
				bCancelar = new JToggleButton();
				getContentPane().add(bCancelar);
				bCancelar.setText("Cancelar");
				bCancelar.setBounds(324, 429, 110, 23);
				bCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("bCerrar.actionPerformed, event="
								+ evt);
						dispose();

					}
				});
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(-26, 417, 762, 10);
			}
			{
				bQuitar = new JButton();
				getContentPane().add(bQuitar);
				bQuitar.setText("Quitar");
				bQuitar.setBounds(479, 131, 71, 21);
			}
			pack();
			this.setSize(576, 501);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

}
